import request from '@/utils/request';
import type { AxiosPromise } from 'axios';

export interface BannerVO {
  bannerId: number;
  title: string;
  imageUrl: string;
  sortOrder: number;
  status: string;
  remark: string;
}

export interface BannerForm {
  bannerId?: number;
  title: string;
  imageUrl: string;
  sortOrder?: number;
  status?: string;
  remark?: string;
}

export interface BannerQuery extends PageQuery {
  title?: string;
  status?: string;
}

/**
 * 查询轮播图列表
 */
export function listBanner(query: BannerQuery): AxiosPromise<BannerVO[]> {
  return request({
    url: '/admin/beauty/banner/list',
    method: 'get',
    params: query
  });
}

/**
 * 查询轮播图详细
 */
export function getBanner(bannerId: number): AxiosPromise<BannerVO> {
  return request({
    url: '/admin/beauty/banner/' + bannerId,
    method: 'get'
  });
}

/**
 * 新增轮播图
 */
export function addBanner(data: BannerForm): AxiosPromise<void> {
  return request({
    url: '/admin/beauty/banner',
    method: 'post',
    data: data
  });
}

/**
 * 修改轮播图
 */
export function updateBanner(data: BannerForm): AxiosPromise<void> {
  return request({
    url: '/admin/beauty/banner',
    method: 'put',
    data: data
  });
}

/**
 * 删除轮播图
 */
export function delBanner(bannerId: number | Array<number>): AxiosPromise<void> {
  return request({
    url: '/admin/beauty/banner/' + bannerId,
    method: 'delete'
  });
}

/**
 * 导出轮播图
 */
export function exportBanner(query: BannerQuery): AxiosPromise<Blob> {
  return request({
    url: '/admin/beauty/banner/export',
    method: 'post',
    params: query,
    responseType: 'blob'
  });
}
